package org.example.scenicspot.persistence;

import org.apache.ibatis.annotations.*;
import org.example.scenicspot.domain.Staff;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface staffMapper {
    @Select("select * from staffmsg")
    List<Staff> selectAll();

    @Select("SELECT * FROM staffmsg WHERE staffmsg.name LIKE CONCAT('%', #{name}, '%')")
    List<Staff> selectByName(@Param("name") String name);



    @Select("SELECT * FROM staffmsg WHERE ScenicAreaID = #{ScenicAreaID}")
    List<Staff> selectByScenicAreaID(int ScenicAreaID);

    @Delete("DELETE FROM staffmsg WHERE staffmsg.id = #{id}")
    int deleteById(@Param("id") int id);

    @Insert("INSERT INTO staffmsg (id,name,Role,ContactInfo,ScenicAreaID) VALUES (#{id},#{name}, #{Role}, #{ContactInfo}, #{ScenicAreaID})")
    void insert(int id,String name,String Role,String ContactInfo,int ScenicAreaID);

    @Update("UPDATE staffmsg SET name = #{name}, Role = #{Role}, ContactInfo = #{ContactInfo}, " +
            "ScenicAreaID = #{ScenicAreaID} WHERE id = #{id}")
    void update(int id,String name,String Role,String ContactInfo,int ScenicAreaID);
}
